package com.lik888.web1;

import com.esotericsoftware.kryo.serializers.FieldSerializer;
import jakarta.validation.constraints.NotNull;
import lombok.SneakyThrows;
import org.apache.http.HttpHost;
import org.apache.ibatis.annotations.Mapper;
import org.checkerframework.checker.units.qual.A;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.crypto.password.PasswordEncoder;

@SpringBootApplication
@EnableAspectJAutoProxy
@MapperScan("com.lik888.web1.mapper")
@EnableScheduling //开启定时任务
public class Web1Application {
    public static void main(String[] args) {
        SpringApplication.run(Web1Application.class, args);

    }
    // 应用启动后创建实例化一个highLevelClient
    @Bean(destroyMethod = "close")
    public RestHighLevelClient elasticsearchClient() {
        System.out.println("创建 Elasticsearch Client, 连接到: " + "192.168.48.128" + ":" + 9200);
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("192.168.48.128", 9200, "http")
                )
        );
    }
}
